home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / cislib_a / entryb.act < prev    next >
Text File  |  1995-04-22  |  3KB  |  151 lines

  1. ;************************************
  2. ;*                                  *
  3. ;*(C)Copyright 1986 by Paul B. Loux *
  4. ;*                                  *
  5. ;* These routines are in the public *
  6. ;* domain,  and  are not to be sold *
  7. ;* for a profit. They may be freely *
  8. ;* distributed, provided  that this *
  9. ;* header remains in place. Use and *
  10. ;* enjoy! PBL, CIS 72337,2073.      *
  11. ;*                                  *
  12. ;************************************
  13. ;
  14. ;  FILE BYTE FUNC EntryB()
  15. ;
  16. ;  Universal byte-entry routine,
  17. ;  requires PROC EntryS, the
  18. ;  universal string entry routine.
  19. ;  This routine takes input from
  20. ;  K: in string form (through
  21. ;  EntryS) and checks for legal
  22. ;  value (<=255) and other useful
  23. ;  features before converting to
  24. ;  an actual BYTE value.
  25. ;
  26. ;  Includes range check, execute
  27. ;  on single digit flag, a null-
  28. ;  entry ok flag, and uses the
  29. ;  the same xit flag as EntryS.
  30. ;  Use of EntryS allows the same
  31. ;  user interface (ESC and ^-Z
  32. ;  handling, timeouts, etc.)
  33. ;
  34. ;  Parameters are self-explanatory;
  35. ;  minval and maxval are the range
  36. ;  limits for acceptable response
  37. ;  (limted to 0-255 of course); the
  38. ;  XEQ, XIT and nullok flags are
  39. ;  1 or yes and 0 for no.
  40. ;
  41. ;************************************
  42. ;
  43.  INCLUDE "ENTRYS.ACT"
  44. ;
  45. ;************************************
  46.  
  47. BYTE FUNC EntryB(BYTE col,row,minval,
  48.                 maxval,nullok,xeq,xit
  49.                 BYTE POINTER err_ptr)
  50.  
  51. BYTE ARRAY limit(0)="255",
  52.            field(0)="..."
  53. BYTE fldlen=field
  54.  
  55. BYTE accept,min,max,
  56.      typec,value
  57.  
  58. INT chk
  59.  
  60. min=0
  61. IF minval>0 THEN min==+1 FI
  62. IF minval>10 THEN min==+1 FI
  63. IF minval>100 THEN min==+1 FI
  64. IF nullok THEN
  65.  min=0 
  66. FI
  67.  
  68. IF maxval=0 THEN
  69.  maxval=255
  70.  max=3
  71. ELSE
  72.  max=0
  73. IF maxval>0 THEN max==+1 FI
  74. IF maxval>10 THEN max==+1 FI
  75. IF maxval>100 THEN max==+1 FI
  76. FI
  77.  
  78. typec=5               ; pos int
  79. accept=0
  80. chk=0
  81.  
  82. DO
  83.  ENTRYS(field,min,max,typec,xit,
  84.         col,row,err_ptr)
  85.        
  86.  IF err_ptr^#0 THEN RETURN(0) FI
  87. ;(calling routine does error handling)
  88.  
  89.  IF fldlen=0 THEN
  90.   field(1)='0
  91.   field(0)=1
  92.  FI
  93.  
  94.  IF fldlen=3 THEN          ; overflow
  95.   chk=SCOMPARE(field,limit)
  96.  FI
  97.  IF chk>0 THEN
  98.   chk=0
  99.   MSG(7)
  100.  ELSE
  101.   value=VALB(field)
  102.   IF value<minval OR value>maxval
  103.    THEN MSG(7)
  104.   ELSE accept=1
  105.   FI
  106.  FI
  107.  
  108. UNTIL accept
  109. OD
  110.  
  111. RETURN(value)
  112.  
  113. ;************************************
  114. ;
  115. ; Example of use of EntryB()
  116.  
  117. PROC Test2()
  118.  
  119. BYTE x,y,min,max,nullflg,value
  120. BYTE errcde
  121. BYTE POINTER err_ptr
  122.  
  123. errcde=0
  124. err_ptr=@errcde
  125.  
  126. min=100
  127. max=200
  128.  
  129. nullflg=0
  130. x=15  y=7
  131.  
  132. PUT(125)
  133. POSITION(5,5)
  134. PUTE()
  135. PRINTE("Enter a number between ")
  136. PRINTB(min)
  137. PRINT(" and ")
  138. PRINTB(max)
  139. PRINT(": ")
  140.  
  141. value=EntryB(X,Y,min,max,nullflg,
  142.              0,0,err_ptr)
  143.  
  144. POSITION(5,10)
  145. PUTE()
  146. PRINTBE(value)
  147. PRINTE("Done...")
  148.  
  149. RETURN
  150.  
  151.